<!--
**********************************************************
* @Author: 张小平
* @Date:   2024-05-01
* @Email:  qqshuqian@163.com
* @Last modified: 最后修改日期
* @Description: 文件描述
**********************************************************
-->
<template>
    <div class="user">
        <basic-container>
            <avue-crud
                    v-model="form"
                    v-model:page="page"
                    v-model:search="searchForm"
                    :permission="getPermission"
                    v-bind="bindVal"
                    v-on="onEvent"
                    :option="option"
                    :data="tableData"
            >
              <template #menu="{size,row,index}">
                <el-button link type="primary"  size="small" icon="el-icon-lock" @click="review(row,index)">查看</el-button>
              </template>
            </avue-crud>

        </basic-container>


    </div>
</template>

<script>
    import taskAPI from '@/framework-code/api/task'
    import curdMixin from '@/framework-core/mixins/crud';
    import website  from '@/framework-core/config/website';

    import {tableOption} from "./index";

    export default {
        name: "myTodo",
        mixins: [curdMixin],
        data() {
            return {
                pageConfig: {name: "我的待办", "url": "/api/flow/flow-ext"},
                searchForm: {},
                loading: false,
                form: {},
                tableData2:[],
                page: {
                    total: 0, // 总页数
                    currentPage: 1, // 当前页数
                    pageSize: website.pageSize // 每页显示多少条
                },
                option: tableOption
            }
        },
        computed: {
            ...mapState({
                permissions: (state) =>state.user.permission,
            })

        },
        created() {
            this.init();
        },
        methods: {
            init() {
            },
            getPermission: function (key, row, index) {
                return this.getCommPermission(key, row, index);
            },
          review(row) {
            const routeData =  this.$router.resolve({
              path: "/form/preview",
              query: {
                formId: row.formId,
                dataId: row.businessKey,
                taskId:row.taskId,
                pageKey:"VIEW",
                flowKey:row.processDefinitionKey
              }
            })

            window.open(routeData.href, '_blank');
          },

            getPage() {
                if( this.searchForm.businessTitle){
                    this.searchForm.keyword =this.searchForm.businessTitle;
                }
                this.loading = true;
                this.tableData = [];
                this.page.total = 0;
                taskAPI.apiMyTodoClaim(
                    this.buildParam()
                )
                    .then(response => {
                        this.tableData = response.data.data.data.records;
                        this.page.total = response.data.data.data.total;
                        this.$message.success('获取成功')
                        this.loading = false;
                    })
                    .catch(() => {
                        this.loading = false;
                    });
                return;
            },
        }
    };
</script>
<style lang="scss">

</style>
